﻿namespace Homework2_4
{
    /// <summary>
    /// open the hello.txt and input another time in it
    /// </summary>
    internal class Program
    {
        static void Main(string[] args)
        {
            //find the file.
            string filePath = @"D:\CSharp2024\hello.txt";

            // get the current time
            string currentTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            // open the file and put the new time into in it
            using (StreamWriter writer = File.AppendText(filePath))
            {
                writer.WriteLine(currentTime);
            }

            Console.WriteLine($"当前时间 {currentTime} 已追加到文件 {filePath}");
        }
    } 
}

